package com.smart.sso.server.controller.admin;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.smart.sso.server.controller.common.BaseController;
import com.smart.sso.server.model.Operationlog;
import com.smart.sso.server.service.OperationlogService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;

/**
 * @author YM
 */
@Api(tags = "日志管理")
@Controller
@RequestMapping("/admin/operationlog")
public class OperationlogController extends BaseController {

	@Resource
	private OperationlogService operationlogService;
	
	@ApiOperation("日志树节点")
	@RequestMapping(value = "/nodes", method = RequestMethod.GET)
	public @ResponseBody List<Operationlog> nodes(
			@ApiParam(value = "应用id") Integer appId,
			@ApiParam(value = "角色id") Integer roleId,
			@ApiParam(value = "是否启用 ") Boolean isEnable) {
		List<Operationlog> list = operationlogService.findByAppId(appId, roleId, isEnable);
		Operationlog permission = new Operationlog();
		permission.setId(null);
		permission.setParentId(-1);
		permission.setName("根节点");
		permission.setAppId(appId);
		list.add(0, permission);
		return list;
	}
}
